<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Chapter 11. Test Doubles</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <link rel="stylesheet" href="docbook.css" tppabs="http://www.phpunit.de/manual/current/en/docbook.css" type="text/css"></link>
</head>
<body>

<div id="header">
  <h1>PHPUnit Manual</h1>

  <ul>
<li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.4/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.4/en/index.html'" tppabs="http://www.phpunit.de/manual/3.4/en/index.html">PHPUnit 3.4 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.3/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.3/en/index.html'" tppabs="http://www.phpunit.de/manual/3.3/en/index.html" class="active">PHPUnit 3.3 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.2/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.2/en/index.html'" tppabs="http://www.phpunit.de/manual/3.2/en/index.html">PHPUnit 3.2 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.1/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.1/en/index.html'" tppabs="http://www.phpunit.de/manual/3.1/en/index.html">PHPUnit 3.1 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.0/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.0/en/index.html'" tppabs="http://www.phpunit.de/manual/3.0/en/index.html">PHPUnit 3.0 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/2.3/en/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/2.3/en/index.html'" tppabs="http://www.phpunit.de/manual/2.3/en/index.html">PHPUnit 2.3 <span><small>English</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.3/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.3/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.3/ja/index.html">PHPUnit 3.3 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.2/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.2/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.2/ja/index.html">PHPUnit 3.2 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.1/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.1/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.1/ja/index.html">PHPUnit 3.1 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/3.0/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/3.0/ja/index.html'" tppabs="http://www.phpunit.de/manual/3.0/ja/index.html">PHPUnit 3.0 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/2.3/ja/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/2.3/ja/index.html'" tppabs="http://www.phpunit.de/manual/2.3/ja/index.html">PHPUnit 2.3 <span><small>Japanese</small></span></a></li><li><a href="javascript:if(confirm('http://www.phpunit.de/manual/2.3/de/index.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/2.3/de/index.html'" tppabs="http://www.phpunit.de/manual/2.3/de/index.html">PHPUnit 2.3 <span><small>German</small></span></a></li>
  </ul>
</div>
<div class="colmask leftmenu">
  <div class="colleft">
    <div class="col1">
      <table border="0" width="100%">
        <tr>
          <td align="left"><a accesskey="p" href="incomplete-and-skipped-tests.html" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html">Prev</a></td>
          <td align="right"><a accesskey="n" href="testing-practices.html" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html">Next</a></td>
        </tr>
      </table>
<div class="chapter" title="Chapter 11. Test Doubles"><div class="titlepage"><div><div><h2 class="title"><a id="test-doubles"></a>Chapter 11. Test Doubles</h2></div></div></div><p>
    Gerard Meszaros introduces the concept of Test Doubles in
    <a class="xref" href="appendixes.bibliography.html#Meszaros2007" tppabs="http://www.phpunit.de/manual/current/en/appendixes.bibliography.html#Meszaros2007" title="xUnit Test Patterns: Refactoring Test Code">[<abbr class="abbrev">Meszaros2007</abbr>]</a> like this:
  </p><div class="blockquote"><table border="0" width="100%" cellspacing="0" cellpadding="0" class="blockquote" summary="Block quote"><tr><td width="10%" valign="top"> </td><td width="80%" valign="top"><p>
      <a id="id2563401" class="indexterm"></a>

      Sometimes it is just plain hard to test the system under test (SUT)
      because it depends on other components that cannot be used in the test
      environment. This could be because they aren't available, they will not
      return the results needed for the test or because executing them would
      have undesirable side effects. In other cases, our test strategy requires
      us to have more control or visibility of the internal behavior of the SUT.
    </p><p>
      <a id="id2563419" class="indexterm"></a>
      <a id="id2563425" class="indexterm"></a>

      When we are writing a test in which we cannot (or chose not to) use a real
      depended-on component (DOC), we can replace it with a Test Double. The
      Test Double doesn't have to behave exactly like the real DOC; it merely
      has to provide the same API as the real one so that the SUT thinks it is
      the real one!
    </p></td><td width="10%" valign="top"> </td></tr><tr><td width="10%" valign="top"> </td><td colspan="2" align="right" valign="top">--<span class="attribution">Gerard Meszaros</span></td></tr></table></div><p>
    <a id="id2563482" class="indexterm"></a>

    You can use a <span class="emphasis"><em>stub</em></span> to "replace a real component on
    which the SUT depends so that the test has a control point for the indirect
    inputs of the SUT. This allows the test to force the SUT down paths it might
    not otherwise execute".
  </p><div class="section" title="Stubs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="test-doubles.stubs"></a>Stubs</h2></div></div></div><p>
      <a id="id2563508" class="indexterm"></a>
      <a id="id2563515" class="indexterm"></a>

      <a class="xref" href="test-doubles.html#test-doubles.stubs.examples.StubTest.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs.examples.StubTest.php" title="Example 11.1: Stubbing a method call to return a fixed value">Example 11.1</a> shows how
      to stub method calls and set up return values. We first use the
      <code class="literal">getMock()</code> method that is provided by the
      <code class="literal">PHPUnit_Framework_TestCase</code> class (see <a class="xref" href="api.html#api.testcase.tables.api" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testcase.tables.api" title="Table 22.6. TestCase">Table 22.6</a>) to set up a stub object that looks
      like an object of <code class="literal">SomeClass</code>. We then use the <a class="ulink" href="javascript:if(confirm('http://martinfowler.com/bliki/FluentInterface.html  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://martinfowler.com/bliki/FluentInterface.html'" tppabs="http://martinfowler.com/bliki/FluentInterface.html" target="_top">Fluent Interface</a>
      that PHPUnit provides to specify the behavior for the stub. In essence,
      this means that you do not need to create several temporary objects and
      wire them together afterwards. Instead, you chain method calls as shown in
      the example. This leads to more readable and "fluent" code.
    </p><div class="example"><a id="test-doubles.stubs.examples.StubTest.php"></a><p class="title"><b>Example 11.1: Stubbing a method call to return a fixed value</b></p><div class="example-contents"><a id="id2564541" class="indexterm"></a><a id="id2564547" class="indexterm"></a><a id="id2564553" class="indexterm"></a><a id="id2564560" class="indexterm"></a><a id="id2564566" class="indexterm"></a><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'PHPUnit/Framework.php'</span><span class="keyword">;</span><br /><span class="default">&nbsp;</span><br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">SomeClass</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">StubTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testStub</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Create&nbsp;a&nbsp;stub&nbsp;for&nbsp;the&nbsp;SomeClass&nbsp;class.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">getMock</span><span class="keyword">(</span><span class="string">'SomeClass'</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Configure&nbsp;the&nbsp;stub.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">expects</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">any</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">method</span><span class="keyword">(</span><span class="string">'doSomething'</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">will</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">returnValue</span><span class="keyword">(</span><span class="string">'foo'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Calling&nbsp;$stub-&gt;doSomething()&nbsp;will&nbsp;now&nbsp;return</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;'foo'.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="string">'foo'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      Sometimes you want to return one of the arguments of a method call
      (unchanged) as the result of a stubbed method call.
      <a class="xref" href="test-doubles.html#test-doubles.stubs.examples.StubTest2.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs.examples.StubTest2.php" title="Example 11.2: Stubbing a method call to return one of the arguments">Example 11.2</a> shows how you
      can achieve this using <code class="literal">returnArgument()</code> instead of
      <code class="literal">returnValue()</code>.
    </p><div class="example"><a id="test-doubles.stubs.examples.StubTest2.php"></a><p class="title"><b>Example 11.2: Stubbing a method call to return one of the arguments</b></p><div class="example-contents"><a id="id2564621" class="indexterm"></a><a id="id2564627" class="indexterm"></a><a id="id2564633" class="indexterm"></a><a id="id2564640" class="indexterm"></a><a id="id2564646" class="indexterm"></a><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">SomeClass</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="default">$argument</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">StubTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testReturnArgumentStub</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Create&nbsp;a&nbsp;stub&nbsp;for&nbsp;the&nbsp;SomeClass&nbsp;class.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">getMock</span><span class="keyword">(</span><span class="string">'SomeClass'</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Configure&nbsp;the&nbsp;stub.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">expects</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">any</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">method</span><span class="keyword">(</span><span class="string">'doSomething'</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">will</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">returnArgument</span><span class="keyword">(</span><span class="default">0</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;$stub-&gt;doSomething('foo')&nbsp;returns&nbsp;'foo'</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="string">'foo'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="string">'foo'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;$stub-&gt;doSomething('bar')&nbsp;returns&nbsp;'bar'</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="string">'bar'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="string">'bar'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      When the stubbed method call should return a calculated value instead of
      a fixed one (see <code class="literal">returnValue()</code>) or an (unchanged)
      argument (see <code class="literal">returnArgument()</code>), you can use
      <code class="literal">returnCallback()</code> to have the stubbed method return the
      result of a callback function or method. See
      <a class="xref" href="test-doubles.html#test-doubles.stubs.examples.StubTest3.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs.examples.StubTest3.php" title="Example 11.3: Stubbing a method call to return a value from a callback">Example 11.3</a> for an example.
    </p><div class="example"><a id="test-doubles.stubs.examples.StubTest3.php"></a><p class="title"><b>Example 11.3: Stubbing a method call to return a value from a callback</b></p><div class="example-contents"><a id="id2564708" class="indexterm"></a><a id="id2564714" class="indexterm"></a><a id="id2564721" class="indexterm"></a><a id="id2564727" class="indexterm"></a><a id="id2564733" class="indexterm"></a><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">SomeClass</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="default">$argument</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">StubTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testReturnCallbackStub</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Create&nbsp;a&nbsp;stub&nbsp;for&nbsp;the&nbsp;SomeClass&nbsp;class.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">getMock</span><span class="keyword">(</span><span class="string">'SomeClass'</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Configure&nbsp;the&nbsp;stub.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">expects</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">any</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">method</span><span class="keyword">(</span><span class="string">'doSomething'</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">will</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">returnCallback</span><span class="keyword">(</span><span class="string">'str_rot13'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;$stub-&gt;doSomething($argument)&nbsp;returns&nbsp;str_rot13($argument)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertEquals</span><span class="keyword">(</span><span class="string">'fbzrguvat'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="string">'something'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      Instead of returning a value, a stubbed method can also raise an
      exception. <a class="xref" href="test-doubles.html#test-doubles.stubs.examples.StubTest4.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs.examples.StubTest4.php" title="Example 11.4: Stubbing a method call to throw an exception">Example 11.4</a>
      shows how to use <code class="literal">throwException()</code> to do this.
    </p><div class="example"><a id="test-doubles.stubs.examples.StubTest4.php"></a><p class="title"><b>Example 11.4: Stubbing a method call to throw an exception</b></p><div class="example-contents"><a id="id2564782" class="indexterm"></a><a id="id2564788" class="indexterm"></a><a id="id2564794" class="indexterm"></a><a id="id2564801" class="indexterm"></a><a id="id2564807" class="indexterm"></a><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">SomeClass</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">StubTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testThrowExceptionStub</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Create&nbsp;a&nbsp;stub&nbsp;for&nbsp;the&nbsp;SomeClass&nbsp;class.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">getMock</span><span class="keyword">(</span><span class="string">'SomeClass'</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Configure&nbsp;the&nbsp;stub.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">expects</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">any</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">method</span><span class="keyword">(</span><span class="string">'doSomething'</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">will</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">throwException</span><span class="keyword">(</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">Exception</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;$stub-&gt;doSomething()&nbsp;throws&nbsp;Exception</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$stub</span><span class="keyword">-&gt;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      Alternatively, you can write the stub yourself and improve your design
      along the way. Widely used resources are accessed through a single façade,
      so you can easily replace the resource with the stub. For example,
      instead of having direct database calls scattered throughout the code,
      you have a single <code class="literal">Database</code> object, an implementor of
      the <code class="literal">IDatabase</code> interface. Then, you can create a stub
      implementation of <code class="literal">IDatabase</code> and use it for your
      tests. You can even create an option for running the tests with the
      stub database or the real database, so you can use your tests for both
      local testing during development and integration testing with the real
      database.
    </p><p>
      Functionality that needs to be stubbed out tends to cluster in the same
      object, improving cohesion. By presenting the functionality with a
      single, coherent interface you reduce the coupling with the rest of the
      system.
    </p></div><div class="section" title="Mock Objects"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="test-doubles.mock-objects"></a>Mock Objects</h2></div></div></div><p>
      <a id="id2564886" class="indexterm"></a>

      You can use a <span class="emphasis"><em>mock object</em></span> "as an observation point
      that is used to verify the indirect outputs of the SUT as it is exercised.
      Typically, the mock object also includes the functionality of a test stub
      in that it must return values to the SUT if it hasn't already failed the
      tests but the emphasis is on the verification of the indirect outputs.
      Therefore, a mock object is lot more than just a test stub plus
      assertions; it is used a fundamentally different way".
    </p><p>
      Sometimes you need to check that an object has been called correctly.
      Here is an example: suppose we want to test that the correct method,
      <code class="literal">update()</code> in our example, is called on an object that
      observes another object.
    </p><p>
      <a id="id2564919" class="indexterm"></a>

      In <a class="xref" href="test-doubles.html#test-doubles.mock-objects.examples.ObserverTest.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects.examples.ObserverTest.php" title="Example 11.5: Testing that a methods gets called once and with a specified parameter">Example 11.5</a>
      we first use the <code class="literal">getMock()</code> method that is provided by
      the <code class="literal">PHPUnit_Framework_TestCase</code> class (see <a class="xref" href="api.html#api.testcase.tables.api" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testcase.tables.api" title="Table 22.6. TestCase">Table 22.6</a>) to set up a mock object for the
      <code class="literal">Observer</code>. Since we give an array as the second
      (optional) parameter for the <code class="literal">getMock()</code> method, only
      the <code class="literal">update()</code> method of the <code class="literal">Observer</code>
      class is replaced by a mock implementation.
    </p><div class="example"><a id="test-doubles.mock-objects.examples.ObserverTest.php"></a><p class="title"><b>Example 11.5: Testing that a methods gets called once and with a specified parameter</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'PHPUnit/Framework.php'</span><span class="keyword">;</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">Subject</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="default">$observers</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">attach</span><span class="keyword">(</span><span class="default">Observer</span><span class="default">&nbsp;</span><span class="default">$observer</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">observers</span><span class="keyword">[</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$observer</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;...</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Notify&nbsp;observers&nbsp;that&nbsp;we&nbsp;did&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">notify</span><span class="keyword">(</span><span class="string">'something'</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">notify</span><span class="keyword">(</span><span class="default">$argument</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">foreach</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">observers</span><span class="default">&nbsp;</span><span class="keyword">as</span><span class="default">&nbsp;</span><span class="default">$observer</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$observer</span><span class="keyword">-&gt;</span><span class="default">update</span><span class="keyword">(</span><span class="default">$argument</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">Observer</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">update</span><span class="keyword">(</span><span class="default">$argument</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;something.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">ObserverTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testUpdateIsCalledOnce</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Create&nbsp;a&nbsp;mock&nbsp;for&nbsp;the&nbsp;Observer&nbsp;class.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$observer</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">getMock</span><span class="keyword">(</span><span class="string">'Observer'</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Set&nbsp;up&nbsp;the&nbsp;expectation&nbsp;for&nbsp;the&nbsp;update()&nbsp;method</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;to&nbsp;be&nbsp;called&nbsp;only&nbsp;once&nbsp;and&nbsp;with&nbsp;the&nbsp;string&nbsp;'something'</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;as&nbsp;its&nbsp;parameter.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$observer</span><span class="keyword">-&gt;</span><span class="default">expects</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">once</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">method</span><span class="keyword">(</span><span class="string">'update'</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">-&gt;</span><span class="default">with</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">equalTo</span><span class="keyword">(</span><span class="string">'something'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Create&nbsp;a&nbsp;Subject&nbsp;object&nbsp;and&nbsp;attach&nbsp;the&nbsp;mocked</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Observer&nbsp;object&nbsp;to&nbsp;it.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$subject</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">Subject</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$subject</span><span class="keyword">-&gt;</span><span class="default">attach</span><span class="keyword">(</span><span class="default">$observer</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Call&nbsp;the&nbsp;doSomething()&nbsp;method&nbsp;on&nbsp;the&nbsp;$subject&nbsp;object</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;which&nbsp;we&nbsp;expect&nbsp;to&nbsp;call&nbsp;the&nbsp;mocked&nbsp;Observer&nbsp;object's</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;update()&nbsp;method&nbsp;with&nbsp;the&nbsp;string&nbsp;'something'.</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$subject</span><span class="keyword">-&gt;</span><span class="default">doSomething</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      <a class="xref" href="api.html#api.assert.assertThat.tables.constraints" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertThat.tables.constraints" title="Table 22.1. Constraints">Table 22.1</a> shows the
      constraints and <a class="xref" href="test-doubles.html#test-doubles.mock-objects.tables.matchers" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects.tables.matchers" title="Table 11.1. Matchers">Table 11.1</a>
      shows the matchers that are available.
    </p><div class="table"><a id="test-doubles.mock-objects.tables.matchers"></a><p class="title"><b>Table 11.1. Matchers</b></p><div class="table-contents"><table summary="Matchers" border="1"><colgroup><col></col><col></col></colgroup><thead><tr><th align="left">Matcher</th><th align="left">Meaning</th></tr></thead><tbody><tr><td align="left"><code class="literal">PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount any()</code></td><td align="left">Returns a matcher that matches when the method it is evaluated for is executed zero or more times.</td></tr><tr><td align="left"><code class="literal">PHPUnit_Framework_MockObject_Matcher_InvokedCount never()</code></td><td align="left">Returns a matcher that matches when the method it is evaluated for is never executed.</td></tr><tr><td align="left"><code class="literal">PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce atLeastOnce()</code></td><td align="left">Returns a matcher that matches when the method it is evaluated for is executed at least once.</td></tr><tr><td align="left"><code class="literal">PHPUnit_Framework_MockObject_Matcher_InvokedCount once()</code></td><td align="left">Returns a matcher that matches when the method it is evaluated for is executed exactly once.</td></tr><tr><td align="left"><code class="literal">PHPUnit_Framework_MockObject_Matcher_InvokedCount exactly(int $count)</code></td><td align="left">Returns a matcher that matches when the method it is evaluated for is executed exactly <code class="literal">$count</code> times.</td></tr><tr><td align="left"><code class="literal">PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex at(int $index)</code></td><td align="left">Returns a matcher that matches when the method it is evaluated for is invoked at the given <code class="literal">$index</code>.</td></tr></tbody></table></div></div><br class="table-break"></br></div><div class="section" title="Mocking the Filesystem"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="test-doubles.mocking-the-filesystem"></a>Mocking the Filesystem</h2></div></div></div><p>
      <a class="ulink" href="javascript:if(confirm('http://code.google.com/p/bovigo/wiki/vfsStream  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://code.google.com/p/bovigo/wiki/vfsStream'" tppabs="http://code.google.com/p/bovigo/wiki/vfsStream" target="_top">vfsStream</a>
      is a <a class="ulink" href="javascript:if(confirm('http://www.php.net/streams  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://www.php.net/streams'" tppabs="http://www.php.net/streams" target="_top">stream wrapper</a> for a
      <a class="ulink" href="javascript:if(confirm('http://en.wikipedia.org/wiki/Virtual_file_system  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://en.wikipedia.org/wiki/Virtual_file_system'" tppabs="http://en.wikipedia.org/wiki/Virtual_file_system" target="_top">virtual
      filesystem</a> that may be helpful in unit tests to mock the real
      filesystem.
    </p><p>
      To install vfsStream, the PEAR channel
      (<code class="systemitem">pear.php-tools.net</code>) that is used for
      its distribution needs to be registered with the local PEAR environment:
    </p><pre class="screen"><strong class="userinput"><code>pear channel-discover pear.php-tools.net</code></strong></pre><p>
      This has to be done only once. Now the PEAR Installer can be used to
      install vfsStream:
    </p><pre class="screen"><strong class="userinput"><code>pear install pat/vfsStream-alpha</code></strong></pre><p>
      <a class="xref" href="test-doubles.html#test-doubles.mocking-the-filesystem.examples.Example.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-the-filesystem.examples.Example.php" title="Example 11.6: A class that interacts with the filesystem">Example 11.6</a>
      shows a class that interacts with the filesystem.
    </p><div class="example"><a id="test-doubles.mocking-the-filesystem.examples.Example.php"></a><p class="title"><b>Example 11.6: A class that interacts with the filesystem</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">Example</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="default">$id</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="default">$directory</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">__construct</span><span class="keyword">(</span><span class="default">$id</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">id</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$id</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">setDirectory</span><span class="keyword">(</span><span class="default">$directory</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">directory</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$directory</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">DIRECTORY_SEPARATOR</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">id</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">file_exists</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">directory</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">mkdir</span><span class="keyword">(</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">directory</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">0700</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">TRUE</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      Without a virtual filesystem such as vfsStream we cannot test the
      <code class="literal">setDirectory()</code> method in isolation from external
      influence (see <a class="xref" href="test-doubles.html#test-doubles.mocking-the-filesystem.examples.ExampleTest.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-the-filesystem.examples.ExampleTest.php" title="Example 11.7: Testing a class that interacts with the filesystem">Example 11.7</a>).
    </p><div class="example"><a id="test-doubles.mocking-the-filesystem.examples.ExampleTest.php"></a><p class="title"><b>Example 11.7: Testing a class that interacts with the filesystem</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'Example.php'</span><span class="keyword">;</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">ExampleTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">setUp</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">file_exists</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="string">'/id'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">rmdir</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="string">'/id'</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testDirectoryIsCreated</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$example</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">Example</span><span class="keyword">(</span><span class="string">'id'</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertFalse</span><span class="keyword">(</span><span class="default">file_exists</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="string">'/id'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$example</span><span class="keyword">-&gt;</span><span class="default">setDirectory</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertTrue</span><span class="keyword">(</span><span class="default">file_exists</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="string">'/id'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">tearDown</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">file_exists</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="string">'/id'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">rmdir</span><span class="keyword">(</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="string">'/id'</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      The approach above has several drawbacks:
    </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>As with any external resource, there might be intermittent problems with the filesystem. This makes tests interacting with it flaky.</p></li><li class="listitem"><p>In the <code class="literal">setUp()</code> and <code class="literal">tearDown()</code> methods we have to ensure that the directory does not exist before and after the test.</p></li><li class="listitem"><p>When the test execution terminates before the <code class="literal">tearDown()</code> method is invoked the directory will stay in the filesystem.</p></li></ul></div><p>
      <a class="xref" href="test-doubles.html#test-doubles.mocking-the-filesystem.examples.ExampleTest2.php" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-the-filesystem.examples.ExampleTest2.php" title="Example 11.8: Mocking the filesystem in a test for a class that interacts with the filesystem">Example 11.8</a>
      shows how vfsStream can be used to mock the filesystem in a test for a
      class that interacts with the filesystem.
    </p><div class="example"><a id="test-doubles.mocking-the-filesystem.examples.ExampleTest2.php"></a><p class="title"><b>Example 11.8: Mocking the filesystem in a test for a class that interacts with the filesystem</b></p><div class="example-contents"><pre class="programlisting"><code><span class="default">&lt;?php</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'vfsStream/vfsStream.php'</span><span class="keyword">;</span><br /><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="string">'Example.php'</span><span class="keyword">;</span><br />&nbsp;<br /><span class="keyword">class</span><span class="default">&nbsp;</span><span class="default">ExampleTest</span><span class="default">&nbsp;</span><span class="keyword">extends</span><span class="default">&nbsp;</span><span class="default">PHPUnit_Framework_TestCase</span><br /><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">setUp</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">vfsStreamWrapper</span><span class="keyword">::</span><span class="default">register</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">vfsStreamWrapper</span><span class="keyword">::</span><span class="default">setRoot</span><span class="keyword">(</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">vfsStreamDirectory</span><span class="keyword">(</span><span class="string">'exampleDir'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">testDirectoryIsCreated</span><span class="keyword">(</span><span class="keyword">)</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$example</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">Example</span><span class="keyword">(</span><span class="string">'id'</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertFalse</span><span class="keyword">(</span><span class="default">vfsStreamWrapper</span><span class="keyword">::</span><span class="default">getRoot</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">-&gt;</span><span class="default">hasChild</span><span class="keyword">(</span><span class="string">'id'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br />&nbsp;<br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$example</span><span class="keyword">-&gt;</span><span class="default">setDirectory</span><span class="keyword">(</span><span class="default">vfsStream</span><span class="keyword">::</span><span class="default">url</span><span class="keyword">(</span><span class="string">'exampleDir'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="keyword">-&gt;</span><span class="default">assertTrue</span><span class="keyword">(</span><span class="default">vfsStreamWrapper</span><span class="keyword">::</span><span class="default">getRoot</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">-&gt;</span><span class="default">hasChild</span><span class="keyword">(</span><span class="string">'id'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span><br /><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><br /><span class="keyword">}</span><br /><span class="default">?&gt;</span><br /></code></pre></div></div><br class="example-break"></br><p>
      This has several advantages:
    </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>The test itself is more concise.</p></li><li class="listitem"><p>vfsStream gives the test developer full control over what the filesystem environment looks like to the tested code.</p></li><li class="listitem"><p>Since the filesystem operations do not operate on the real filesystem anymore, cleanup operations in a <code class="literal">tearDown()</code> method are no longer required.</p></li></ul></div></div></div>
      <table border="0" width="100%">
        <tr>
          <td align="left"><a accesskey="p" href="incomplete-and-skipped-tests.html" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html">Prev</a></td>
          <td align="right"><a accesskey="n" href="testing-practices.html" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html">Next</a></td>
        </tr>
      </table>
    </div>
    <div class="col2">
<dl><dt><span class="chapter"><a href="automating-tests.html" tppabs="http://www.phpunit.de/manual/current/en/automating-tests.html">1. 自动化测试</a></span></dt><dt><span class="chapter"><a href="goals.html" tppabs="http://www.phpunit.de/manual/current/en/goals.html">2. PHPUnit的目标</a></span></dt><dt><span class="chapter"><a href="installation.html" tppabs="http://www.phpunit.de/manual/current/en/installation.html">3. 安装PHPUnit</a></span></dt><dt><span class="chapter"><a href="writing-tests-for-phpunit.html" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html">4. 为PHPUnit编写测试</a></span></dt><dd><dl><dt><span class="section"><a href="writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers">Data Providers</a></span></dt><dt><span class="section"><a href="writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions">Testing Exceptions</a></span></dt><dt><span class="section"><a href="writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors" tppabs="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors">Testing PHP Errors</a></span></dt></dl></dd><dt><span class="chapter"><a href="textui.html" tppabs="http://www.phpunit.de/manual/current/en/textui.html">5. The Command-Line Test Runner</a></span></dt><dt><span class="chapter"><a href="fixtures.html" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html">6. Fixtures</a></span></dt><dd><dl><dt><span class="section"><a href="fixtures.html#fixtures.more-setup-than-teardown" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.more-setup-than-teardown">More setUp() than tearDown()</a></span></dt><dt><span class="section"><a href="fixtures.html#fixtures.variations" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.variations">Variations</a></span></dt><dt><span class="section"><a href="fixtures.html#fixtures.sharing-fixture" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.sharing-fixture">Sharing Fixture</a></span></dt><dt><span class="section"><a href="fixtures.html#fixtures.global-state" tppabs="http://www.phpunit.de/manual/current/en/fixtures.html#fixtures.global-state">Global State</a></span></dt></dl></dd><dt><span class="chapter"><a href="organizing-tests.html" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html">7. Organizing Tests</a></span></dt><dd><dl><dt><span class="section"><a href="organizing-tests.html#organizing-tests.filesystem" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.filesystem">Composing a Test Suite Using the Filesystem</a></span></dt><dt><span class="section"><a href="organizing-tests.html#organizing-tests.xml-configuration" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.xml-configuration">Composing a Test Suite Using XML Configuration</a></span></dt><dt><span class="section"><a href="organizing-tests.html#organizing-tests.testsuite" tppabs="http://www.phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.testsuite">Using the TestSuite Class</a></span></dt></dl></dd><dt><span class="chapter"><a href="testcase-extensions.html" tppabs="http://www.phpunit.de/manual/current/en/testcase-extensions.html">8. TestCase Extensions</a></span></dt><dd><dl><dt><span class="section"><a href="testcase-extensions.html#testcase-extensions.output" tppabs="http://www.phpunit.de/manual/current/en/testcase-extensions.html#testcase-extensions.output">Testing Output</a></span></dt><dt><span class="section"><a href="testcase-extensions.html#testcase-extensions.performance" tppabs="http://www.phpunit.de/manual/current/en/testcase-extensions.html#testcase-extensions.performance">Testing Performance</a></span></dt></dl></dd><dt><span class="chapter"><a href="database.html" tppabs="http://www.phpunit.de/manual/current/en/database.html">9. Database Testing</a></span></dt><dd><dl><dt><span class="section"><a href="database.html#database.datasets" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets">Data Sets</a></span></dt><dd><dl><dt><span class="section"><a href="database.html#database.datasets.flatxml" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.flatxml">Flat XML Data Set</a></span></dt><dt><span class="section"><a href="database.html#database.datasets.xml" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.xml">XML Data Set</a></span></dt><dt><span class="section"><a href="database.html#database.datasets.csv" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.csv">CSV Data Set</a></span></dt><dt><span class="section"><a href="database.html#database.datasets.replacement" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.datasets.replacement">Replacement Data Set</a></span></dt></dl></dd><dt><span class="section"><a href="database.html#database.operations" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.operations">Operations</a></span></dt><dt><span class="section"><a href="database.html#database.bestpractices" tppabs="http://www.phpunit.de/manual/current/en/database.html#database.bestpractices">Database Testing Best Practices</a></span></dt></dl></dd><dt><span class="chapter"><a href="incomplete-and-skipped-tests.html" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html">10. Incomplete and Skipped Tests</a></span></dt><dd><dl><dt><span class="section"><a href="incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.incomplete-tests" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.incomplete-tests">Incomplete Tests</a></span></dt><dt><span class="section"><a href="incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.skipping-tests" tppabs="http://www.phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.skipping-tests">Skipping Tests</a></span></dt></dl></dd><dt><span class="chapter"><a href="test-doubles.html" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html" class="active">11. Test Doubles</a></span></dt><dd><dl><dt><span class="section"><a href="test-doubles.html#test-doubles.stubs" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs">Stubs</a></span></dt><dt><span class="section"><a href="test-doubles.html#test-doubles.mock-objects" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects">Mock Objects</a></span></dt><dt><span class="section"><a href="test-doubles.html#test-doubles.mocking-the-filesystem" tppabs="http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-the-filesystem">Mocking the Filesystem</a></span></dt></dl></dd><dt><span class="chapter"><a href="testing-practices.html" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html">12. Testing Practices</a></span></dt><dd><dl><dt><span class="section"><a href="testing-practices.html#testing-practices.during-development" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html#testing-practices.during-development">During Development</a></span></dt><dt><span class="section"><a href="testing-practices.html#testing-practices.during-debugging" tppabs="http://www.phpunit.de/manual/current/en/testing-practices.html#testing-practices.during-debugging">During Debugging</a></span></dt></dl></dd><dt><span class="chapter"><a href="test-driven-development.html" tppabs="http://www.phpunit.de/manual/current/en/test-driven-development.html">13. Test-Driven Development</a></span></dt><dd><dl><dt><span class="section"><a href="test-driven-development.html#test-driven-development.bankaccount-example" tppabs="http://www.phpunit.de/manual/current/en/test-driven-development.html#test-driven-development.bankaccount-example">BankAccount Example</a></span></dt></dl></dd><dt><span class="chapter"><a href="behaviour-driven-development.html" tppabs="http://www.phpunit.de/manual/current/en/behaviour-driven-development.html">14. Behaviour-Driven Development</a></span></dt><dd><dl><dt><span class="section"><a href="behaviour-driven-development.html#behaviour-driven-development.bowlinggame-example" tppabs="http://www.phpunit.de/manual/current/en/behaviour-driven-development.html#behaviour-driven-development.bowlinggame-example">BowlingGame Example</a></span></dt></dl></dd><dt><span class="chapter"><a href="code-coverage-analysis.html" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html">15. Code Coverage Analysis</a></span></dt><dd><dl><dt><span class="section"><a href="code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods">Specifying Covered Methods</a></span></dt><dt><span class="section"><a href="code-coverage-analysis.html#code-coverage-analysis.ignoring-code-blocks" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.ignoring-code-blocks">Ignoring Code Blocks</a></span></dt><dt><span class="section"><a href="code-coverage-analysis.html#code-coverage-analysis.including-excluding-files" tppabs="http://www.phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.including-excluding-files">Including and Excluding Files</a></span></dt></dl></dd><dt><span class="chapter"><a href="other-uses-for-tests.html" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html">16. Other Uses for Tests</a></span></dt><dd><dl><dt><span class="section"><a href="other-uses-for-tests.html#other-uses-for-tests.agile-documentation" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html#other-uses-for-tests.agile-documentation">Agile Documentation</a></span></dt><dt><span class="section"><a href="other-uses-for-tests.html#other-uses-for-tests.cross-team-tests" tppabs="http://www.phpunit.de/manual/current/en/other-uses-for-tests.html#other-uses-for-tests.cross-team-tests">Cross-Team Tests</a></span></dt></dl></dd><dt><span class="chapter"><a href="skeleton-generator.html" tppabs="http://www.phpunit.de/manual/current/en/skeleton-generator.html">17. Skeleton Generator</a></span></dt><dd><dl><dt><span class="section"><a href="skeleton-generator.html#skeleton-generator.test" tppabs="http://www.phpunit.de/manual/current/en/skeleton-generator.html#skeleton-generator.test">Generating a Test Case Class Skeleton</a></span></dt><dt><span class="section"><a href="skeleton-generator.html#skeleton-generator.class" tppabs="http://www.phpunit.de/manual/current/en/skeleton-generator.html#skeleton-generator.class">Generating a Class Skeleton from a Test Case Class</a></span></dt></dl></dd><dt><span class="chapter"><a href="javascript:if(confirm('http://www.phpunit.de/manual/current/en/selenium.html  \n\nļδ Teleport Pro ȡأΪ ޷ȡãȡغĿֹ̫ͣ졣  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/current/en/selenium.html'" tppabs="http://www.phpunit.de/manual/current/en/selenium.html">18. PHPUnit and Selenium</a></span></dt><dd><dl><dt><span class="section"><a href="javascript:if(confirm('http://www.phpunit.de/manual/current/en/selenium.html  \n\nļδ Teleport Pro ȡأΪ ޷ȡãȡغĿֹ̫ͣ졣  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/current/en/selenium.html#selenium.selenium-rc'" tppabs="http://www.phpunit.de/manual/current/en/selenium.html#selenium.selenium-rc">Selenium RC</a></span></dt><dt><span class="section"><a href="javascript:if(confirm('http://www.phpunit.de/manual/current/en/selenium.html  \n\nļδ Teleport Pro ȡأΪ ޷ȡãȡغĿֹ̫ͣ졣  \n\nҪӷϴ'))window.location='http://www.phpunit.de/manual/current/en/selenium.html#selenium.seleniumtestcase'" tppabs="http://www.phpunit.de/manual/current/en/selenium.html#selenium.seleniumtestcase">PHPUnit_Extensions_SeleniumTestCase</a></span></dt></dl></dd><dt><span class="chapter"><a href="logging.html" tppabs="http://www.phpunit.de/manual/current/en/logging.html">19. Logging</a></span></dt><dd><dl><dt><span class="section"><a href="logging.html#logging.xml" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.xml">Test Results (XML)</a></span></dt><dt><span class="section"><a href="logging.html#logging.tap" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.tap">Test Results (TAP)</a></span></dt><dt><span class="section"><a href="logging.html#logging.json" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.json">Test Results (JSON)</a></span></dt><dt><span class="section"><a href="logging.html#logging.codecoverage" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.codecoverage">Code Coverage (XML)</a></span></dt><dt><span class="section"><a href="logging.html#logging.database" tppabs="http://www.phpunit.de/manual/current/en/logging.html#logging.database">Test Database</a></span></dt></dl></dd><dt><span class="chapter"><a href="build-automation.html" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html">20. Build Automation</a></span></dt><dd><dl><dt><span class="section"><a href="build-automation.html#build-automation.ant" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html#build-automation.ant">Apache Ant</a></span></dt><dt><span class="section"><a href="build-automation.html#build-automation.maven" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html#build-automation.maven">Apache Maven</a></span></dt><dt><span class="section"><a href="build-automation.html#build-automation.phing" tppabs="http://www.phpunit.de/manual/current/en/build-automation.html#build-automation.phing">Phing</a></span></dt></dl></dd><dt><span class="chapter"><a href="continuous-integration.html" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html">21. Continuous Integration</a></span></dt><dd><dl><dt><span class="section"><a href="continuous-integration.html#continuous-integration.atlassian-bamboo" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html#continuous-integration.atlassian-bamboo">Atlassian Bamboo</a></span></dt><dt><span class="section"><a href="continuous-integration.html#continuous-integration.cruisecontrol" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html#continuous-integration.cruisecontrol">CruiseControl</a></span></dt><dt><span class="section"><a href="continuous-integration.html#continuous-integration.phpUnderControl" tppabs="http://www.phpunit.de/manual/current/en/continuous-integration.html#continuous-integration.phpUnderControl">phpUnderControl</a></span></dt></dl></dd><dt><span class="chapter"><a href="api.html" tppabs="http://www.phpunit.de/manual/current/en/api.html">22. PHPUnit API</a></span></dt><dd><dl><dt><span class="section"><a href="api.html#api.overview" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.overview">Overview</a></span></dt><dt><span class="section"><a href="api.html#api.assert" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert">PHPUnit_Framework_Assert</a></span></dt><dd><dl><dt><span class="section"><a href="api.html#api.assert.assertArrayHasKey" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertArrayHasKey"><code class="literal">assertArrayHasKey()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertClassHasAttribute" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertClassHasAttribute"><code class="literal">assertClassHasAttribute()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertClassHasStaticAttribute" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertClassHasStaticAttribute"><code class="literal">assertClassHasStaticAttribute()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertContains" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertContains"><code class="literal">assertContains()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertContainsOnly" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertContainsOnly"><code class="literal">assertContainsOnly()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertEqualXMLStructure" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertEqualXMLStructure"><code class="literal">assertEqualXMLStructure()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertEquals" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertEquals"><code class="literal">assertEquals()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertFalse" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertFalse"><code class="literal">assertFalse()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertFileEquals" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertFileEquals"><code class="literal">assertFileEquals()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertFileExists" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertFileExists"><code class="literal">assertFileExists()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertGreaterThan" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertGreaterThan"><code class="literal">assertGreaterThan()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertGreaterThanOrEqual" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertGreaterThanOrEqual"><code class="literal">assertGreaterThanOrEqual()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertLessThan" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertLessThan"><code class="literal">assertLessThan()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertLessThanOrEqual" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertLessThanOrEqual"><code class="literal">assertLessThanOrEqual()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertNotNull" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertNotNull"><code class="literal">assertNotNull()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertObjectHasAttribute" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertObjectHasAttribute"><code class="literal">assertObjectHasAttribute()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertRegExp" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertRegExp"><code class="literal">assertRegExp()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSame" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSame"><code class="literal">assertSame()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSelectCount" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSelectCount"><code class="literal">assertSelectCount()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSelectEquals" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSelectEquals"><code class="literal">assertSelectEquals()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertSelectRegExp" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertSelectRegExp"><code class="literal">assertSelectRegExp()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertStringEqualsFile" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertStringEqualsFile"><code class="literal">assertStringEqualsFile()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertTag" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertTag"><code class="literal">assertTag()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertThat" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertThat"><code class="literal">assertThat()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertTrue" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertTrue"><code class="literal">assertTrue()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertType" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertType"><code class="literal">assertType()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertXmlFileEqualsXmlFile" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertXmlFileEqualsXmlFile"><code class="literal">assertXmlFileEqualsXmlFile()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertXmlStringEqualsXmlFile" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertXmlStringEqualsXmlFile"><code class="literal">assertXmlStringEqualsXmlFile()</code></a></span></dt><dt><span class="section"><a href="api.html#api.assert.assertXmlStringEqualsXmlString" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.assert.assertXmlStringEqualsXmlString"><code class="literal">assertXmlStringEqualsXmlString()</code></a></span></dt></dl></dd><dt><span class="section"><a href="api.html#api.test" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.test">PHPUnit_Framework_Test</a></span></dt><dt><span class="section"><a href="api.html#api.testcase" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testcase">PHPUnit_Framework_TestCase</a></span></dt><dt><span class="section"><a href="api.html#api.testsuite" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testsuite">PHPUnit_Framework_TestSuite</a></span></dt><dt><span class="section"><a href="api.html#api.testresult" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.testresult">PHPUnit_Framework_TestResult</a></span></dt><dt><span class="section"><a href="api.html#api.package-structure" tppabs="http://www.phpunit.de/manual/current/en/api.html#api.package-structure">Package Structure</a></span></dt></dl></dd><dt><span class="chapter"><a href="extending-phpunit.html" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html">23. Extending PHPUnit</a></span></dt><dd><dl><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestCase" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestCase">Subclass PHPUnit_Framework_TestCase</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.Assert" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.Assert">Assert Classes</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Extensions_TestDecorator" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Extensions_TestDecorator">Subclass PHPUnit_Extensions_TestDecorator</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_Test" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_Test">Implement PHPUnit_Framework_Test</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestResult" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestResult">Subclass PHPUnit_Framework_TestResult</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener">Implement PHPUnit_Framework_TestListener</a></span></dt><dt><span class="section"><a href="extending-phpunit.html#extending-phpunit.TestRunner" tppabs="http://www.phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.TestRunner">New Test Runner</a></span></dt></dl></dd><dt><span class="appendix"><a href="appendixes.assertions.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.assertions.html">A. Assertions</a></span></dt><dt><span class="appendix"><a href="appendixes.configuration.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html">B. The XML Configuration File</a></span></dt><dd><dl><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.phpunit" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.phpunit">PHPUnit</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.testsuite" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.testsuite">Test Suite</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.groups" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.groups">Groups</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.blacklist-whitelist" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.blacklist-whitelist">Including and Excluding Files for Code Coverage</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.logging" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.logging">Logging</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables">Setting PHP INI settings, Constants and Global Variables</a></span></dt><dt><span class="section"><a href="appendixes.configuration.html#appendixes.configuration.selenium-rc" tppabs="http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.selenium-rc">Configuring Browsers for Selenium RC</a></span></dt></dl></dd><dt><span class="appendix"><a href="appendixes.index.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.index.html">C. Index</a></span></dt><dd><dl><dt><span class="index"><a href="appendixes.index.html#appendixes.index.index" tppabs="http://www.phpunit.de/manual/current/en/appendixes.index.html#appendixes.index.index"></a></span></dt></dl></dd><dt><span class="appendix"><a href="appendixes.bibliography.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.bibliography.html">D. Bibliography</a></span></dt><dt><span class="appendix"><a href="appendixes.copyright.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.copyright.html">E. Copyright</a></span></dt></dl>
    </div>
  </div>
</div>
<div id="footer">
  <p><a href="appendixes.copyright.html" tppabs="http://www.phpunit.de/manual/current/en/appendixes.copyright.html">Copyright</a> &copy; 2005-2009 <a href="javascript:if(confirm('http://sebastian-bergmann.de/  \n\nļδ Teleport Pro ȡأΪ ·ʼַõķΧ  \n\nҪӷϴ'))window.location='http://sebastian-bergmann.de/'" tppabs="http://sebastian-bergmann.de/">Sebastian Bergmann</a>.</p>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www./");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-68261-7");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>

